package com.spring.boot.rabbit.service.consumer;

import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import static com.spring.boot.rabbit.constant.QueueConstant.DEFAULT_DEAD_LETTER_QUEUE;

/**
 * RabbitMQ-死信队列消费者
 *
 * @author 李坤
 * @date 2022/9/1 17:44
 */
@Service
public class RabbitDeadLetter {

    /**
     * 日志处理器
     */
    private final Logger logger = LoggerFactory.getLogger(RabbitDeadLetter.class);

    @RabbitListener(queues = {DEFAULT_DEAD_LETTER_QUEUE})
    public void processDeadLetter(String body, Message message, Channel channel) {
        logger.info("死信队列-内容: {}", body);
    }

}
